package amani.wechat.platform.controller;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import amani.wechat.platform.core.mvc.RequestStatus;
import amani.wechat.platform.dao.IBaseGenericDAO;
import amani.wechat.platform.dao.entities.AmnConfigs;
import amani.wechat.platform.services.ICommonService;
import amani.wechat.platform.services.IOrdersService;
import amani.wechat.platform.webserviceClient.CommonService;

/**
 *  VIP预约
 *  
 *  
 * @author VV
 *
 */
@Controller
@RequestMapping("/Orders")
public class OrdersController {
	
	@Resource(name="OrdersService")
	IOrdersService ordersService ;
	
	/**
	 * 选择服务类型
	 * @param model
	 * @return
	 */
	@RequestMapping("/Step1")
	public String step1( Model model) {
	    List<String> orderFactProjectList=	ordersService.getOdersFactProject("orCjajmtEXBnBUMNVuQREze-fuVI");
	    model.addAttribute("OrdersFactProject", orderFactProjectList);
	    model.addAttribute("openid","orCjajmtEXBnBUMNVuQREze-fuVI");
		return "orders/step1";
	}
	
	/**
	 * 选择发型师
	 * @param model
	 * @return
	 */
	@RequestMapping("/Step2")
	public String step2(String openid,String ordersFactProject,  Model model) { 
		model.addAttribute("ordersFactProject", ordersFactProject);
	    model.addAttribute("openid",openid);
		
		return "orders/step2";
		
	}
	
	/**
	 * 选择服务时间
	 * @param openid 客户id
	 * @param staffno 员工编号
	 * @param model 页面数据模型
	 * @return
	 */
	@RequestMapping("/Step3")
	public String step3(String openid,String staffno ,String ordersFactProject, Model model) { 
		model.addAttribute("ordersFactProject", ordersFactProject);
	    model.addAttribute("openid",openid); 
	    model.addAttribute("staffno",staffno);
		return "orders/step3";
	}
	
	/**
	 * 确认提交信息
	 * 
	 * @param openid
	 * @param staffno
	 * @param model
	 * @return
	 */
	@RequestMapping("/Step4")
	public String step4(String openid,String staffno,Date orderDate,String ordersFactProject, Model model) { 
		model.addAttribute("ordersFactProject", ordersFactProject);
	    model.addAttribute("openid",openid); 
	    model.addAttribute("staffno",staffno);
	    model.addAttribute("orderDate",orderDate);
		return "orders/step4";
	}
	
	/**
	 * 保存提交预约数据
	 * @param openid
	 * @param staffno
	 * @param orderDate
	 * @param ordersFactProjectl
	 * @return
	 */
	@RequestMapping("/CommitOrder")
	public RequestStatus commitOrders(String openid,String staffno,Date orderDate,String ordersFactProjectl) { 
		RequestStatus requestStatus=new RequestStatus();
		 String strCompId="";
		 String strBillId="";
		 String strCardNo="";
		 String orderPhone="";
		 String strDate="";
		 String strTime="";
		 int billType=0;
		 String complydetail="";
		 boolean isSuccessed= ordersService.saveOrder(strCompId, strBillId, strCardNo, orderPhone, strDate, strTime, openid, billType, complydetail);
		 requestStatus.setIsSuccessed(isSuccessed);
		 return requestStatus;
	}
}
